import 'package:flutter/material.dart';

/// 列表App
class ListViewApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(primarySwatch: Colors.red),
      home: ListViewAppPage(),
    );
  }
}

/// 列表页
class ListViewAppPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => ListViewAppPageState();
}

class ListViewAppPageState extends State<ListViewAppPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('ListView 数据'),
      ),
      body: ListView(
        children: _getListData(),
      ),
    );
  }

  _getListData() {
    List<Widget> widgets = [];
    for (int i = 0; i < 100; i++) {
      widgets.add(GestureDetector(
        child: Padding(
          padding: EdgeInsets.all(10.0),
          child: Text("Row $i"),
        ),
        onTap: () {
          print("点击：$i");
        },
      ));
    }
    return widgets;
  }
}
